<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
include ("../../include/image_slider.php");
include ("../../include/function.php");
include '../../include/dbFunctions.php';

if (isset($_SESSION['school_id'])) {



$event_id = $_SESSION['event_id']; //Make $id become GLOBAL for passing to next page for \further usage

// Select session
$session = "SELECT * FROM session WHERE event_id = $event_id";
$session = executeSelectQuery($session);
}
?>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Junior Achievement Singapore</title>
        <link href="../../media/css/styles.css" rel="stylesheet" type="text/css" />
        <link href="../../media/css/jquery-ui-1.8.13.custom.css" rel="stylesheet" type="text/css" />

        <script type="text/javascript" language="javascript" src="../../media/js/jquery/jquery-1.6.1.min.js"></script>
        <script type="text/javascript" src="../../media/js/jqueryUI/jquery-ui-1.8.13.custom.js"></script>
        <script type="text/javascript" src="../../media/js/jquery/image_slider.js"></script>
        <!-- Custom jquery scripts -->

        <script type="text/javascript" language="javascript" src="../../media/js/jquery/jquery.validate.min.js"></script>
        <script type="text/javascript" src="../../media/js/jquery/validator_rules.js"></script>

        <script type="text/javascript" src="../../media/js/jqueryUI/jquery-ui-timepicker-addon.js"></script>

        <script src="../../media/js/jquery/jquery.maskedinput-1.3.js" type="text/javascript"></script>

        <script type="text/javascript">
            $(document).ready(function(){
                
               
                $("#editevent").validate({
                  
                });
              

                // date picker for choosing date
                $(".date").datepicker({
                    changeMonth:true,
                    minDate: 0
                });

            }
        )
            
            jQuery(function($){   $(".time").mask("99:99");});
            
        </script>

    </head>
    <body>
        <script>
            var timeout    = 500;
            var closetimer = 0;
            var ddmenuitem = 0;

            function jsddm_open()
            {  jsddm_canceltimer();
                jsddm_close();
                ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

            function jsddm_close()
            {  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

            function jsddm_timer()
            {  closetimer = window.setTimeout(jsddm_close, timeout);}

            function jsddm_canceltimer()
            {  if(closetimer)
                {  window.clearTimeout(closetimer);
                    closetimer = null;}}

            $(document).ready(function()
            {  $('#navigation > li').bind('mouseover', jsddm_open)
                $('#navigation > li').bind('mouseout',  jsddm_timer)});

            document.onclick = jsddm_close;
        </script>
        <div id="container"><!--CONTAINER STARTS-->
            <div id="navigation">
                <li><a href="../../include/home/homepage.php">HOME</a></li>
                <li><a href="../../include/home/contact.php">CONTACT</a></li>
                <li><a href="http://ja.org.sg/">ABOUT JA SINGAPORE</a></li>
                <li><a href="http://jascheduling.lefora.com/">FEEDBACK</a></li>
                <li><a href="../../guide/guide_menu.php">HELP</a></li>

            </div>
            <div id="title"><!--TITLE STARTS-->
            </div><!--TITLE ENDS-->
            <div id="featured"><!--FEATURED AREA STARTS-->
                <div class="featured-image"><!--FEATURED IMAGE STARTS-->
                    <img alt="Featured Image" src="../../media/images/featured_image.png"></img>
                </div><!--FEATURED IMAGE ENDS-->
                <div class="featured-text"><!--FEATURED TEXT STARTS-->
                    <h2>Welcome to JA Singapore</h2>
                    <p>Junior Achievement programs help prepare young people for the real world by showing them how to generate wealth and effectively manage it, how to create jobs which make their communities more robust, and how to apply entrepreneurial thinking to the workplace. <a href="http://www.jaworldwide.org/">Read More... </a></p>
                </div><!--FEATURED TEXT ENDS-->
            </div><!--FEATURED AREA ENDS-->
            <?php
            custom_login();
            ?>
            <div id="left-content"><!--RIGHT CONTENT STARTS-->

                <div class="left-top"><!--RIGHT CONTENT BOX TOP-->
                </div><!--RIGHT CONTENT BOX TOP ENDS-->

                <div class="left-middle"><!--RIGHT CONTENT BOX MIDDLE-->
                    <?php
                        if (!isset($_SESSION['school_id'])) {
                      echo "<br/><br/><br/><br/><br/><center><h3>You don't have permission to view this page<h3><br/>";
                    }
                    else{
                    ?>
                      <br><br><br><br>
                    <h3>Edit Sessions</h3>

                    <!-- Display all events, which available for volunteer to participate in-->
                    <form id="editevent" method ="POST" action="representativeDetailEvent.php"  name="frmData" enctype="multipart/form-data" >
                      <br><br>
                        <table ccellpadding="0" cellspacing="0" border="0" class="tablemain" id="eventtable1">
                            <thead>
                            <tr>
                                <th class="tableth">No.</th>             
                                <th class="tableth">Date</th>
                                <th class="tableth">Start time</th>
                                <th class="tableth">End time</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                            for ($i = 0; $i < count($session); $i++) {
                                $new_date = $session[$i]['session_date'];
                                $new_date = explode("-", $new_date);
                                $final_date = "$new_date[1]/$new_date[2]/$new_date[0]";
                                ?>
                                <tr>
                                    <td><?php echo $i + 1 ?></td>
                                    <td> <input type="text" name="date<?php echo $i  ?>" class="date required" value ="<?php echo $final_date ?>"/></td>
                                    <td> <input type="text" name="time<?php echo $i  ?>" class="time required" value ="<?php echo $session[$i]['session_time'] ?>"/></td>
                                    <td> <input type="text" name="end_time<?php echo $i  ?>" class="time required" value ="<?php echo $session[$i]['session_end_time'] ?>"/></td>
                                </tr>

                                <?php
                            }
                            ?>
                            </tbody>
                        </table>
                        <?php $no_session = count($session);  ?>
                       
                        <input type="hidden" name="edit_event" value="1"/>
                        <input type="hidden" name="no_session" value="<?php echo $no_session ?>" />
                        <input type='button' value='&nbsp' class="form-back" onclick='history.go(-1)'/>
                        <input type="submit" value="&nbsp" name="submit" class="form-submit"/>
                    </form>



                    <?php
                        }
                    ?>
                </div><!--RIGHT CONTENT BOX MIDDLE ENDS-->
                <div class="left-bottom"><!--RIGHT CONTENT BOX BOTTOM-->
                </div><!--RIGHT CONTENT BOX BOTTOM ENDS-->
            </div><!--RIGHT CONTENT ENDS-->
        </div><!--CONTAINER ENDS-->
        <div id="footer"><!--FOOTER STARTS-->
            <p>Copyright &copy; Junior Achievement Singapore | All Rights Reserved</p>
        </div><!--FOOTER ENDS-->
    </body>
</html>

